// page/cart/bless.js
var sliderWidth = 96; // 需要设置slider的宽度，用于计算中间位置

Page({
    data: {
        isHide: false,
        tabs: [],
        content: [],
        activeIndex: 0,
        sliderOffset: 0,
        sliderLeft: 0,


    },
    onLoad: function () {
        var that = this;
        var app = getApp()
       
        wx.request({
          url: app.globalData.host + '&g=App&m=Cart&a=bless', //仅为示例，并非真实的接口地址
          header: {
            'content-type': 'application/json'
          },
          success: function (res) {
            console.log(res.data)
            that.setData({
              tabs: res.data.t,
              content: res.data.g,
          
            })
          }
        });


        wx.getSystemInfo({
            success: function (res) {
                that.setData({
                    isHide: true,
                    sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
                    sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
                });
            }
        });
    },
    tabClick: function (e) {
        this.setData({
            sliderOffset: e.currentTarget.offsetLeft,
            activeIndex: e.currentTarget.id
        });
    },
  textClick: function (e) {
    var detail=e.currentTarget.dataset.text
    var pages = getCurrentPages();
    var currPage = pages[pages.length - 1];   //当前页面
    var prevPage = pages[pages.length - 2];  //上个页面

    //直接调用上一个页面的setData()方法，把数据存到上一个页面中去
    prevPage.setData({
      heka: detail
    })
    wx.navigateBack({
      delta: 1
    })
  }
});